/**
 * 
 */
package com.ibl.rover.lite.common.db;

import java.util.List;

import com.ibl.rover.lite.common.bean.BaseBean;

import android.content.ContentValues;
import android.database.Cursor;

public abstract class DatabaseManager {

	public abstract <T extends BaseBean> long saveBean(T bean);

	public abstract <T extends BaseBean> void saveBean(List<T> bean)
			throws BaseException;

	public abstract <T extends BaseBean> int deleteBean(T bean);

	public <T extends BaseBean> int updateBean(List<T> bean)
			throws BaseException {
		return 0;
	}

	public abstract <T extends BaseBean> int updateBean(T bean);

	public abstract <T extends BaseBean> T findBeanById(T bean);

	public abstract <T extends BaseBean> List<T> findAllBean(Class<T> bean)
			throws BaseException;

	public abstract <T extends BaseBean> T findBeanById(Class<T> bean, long id)
			throws BaseException;

	public abstract <T extends BaseBean> Criteria<T> generateCriteria(
			Class<T> bean);

	public abstract Cursor executeSQL(final String sql, String[] selectionArgs);

	public abstract void executeScaler(final String sql) throws BaseException;

	public interface UpdatebeanCriteria {
		public <T extends BaseBean> String getUpdateCriteria(T bean);

		public <T extends BaseBean> ContentValues getUpdateBeanMap(T bean);
	}

	public interface DeleteBeanCriteria {
		public <T extends BaseBean> String getCriteria(T bean);
	}

	abstract public <T extends BaseBean> int updateBean(T bean,
			UpdatebeanCriteria beranCriteria);

	abstract public <T extends BaseBean> int updateBean(List<T> entityList,
			UpdatebeanCriteria beanCriteria);

	abstract public <T extends BaseBean> int deleteBean(T entity,
			UpdatebeanCriteria beanCriteria);

	abstract <T extends BaseBean> List<T> findBean(Class<T> bean, String where,
			String orderBy) throws BaseException;

	public abstract <T extends BaseBean> Cursor executeDistinctSQL(Class<T> bean,
			String[] selectionArgs) throws BaseException;

	// abstract <T extends BaseBean> List<T> findBean(Class<T> bean, String
	// where,
	// String orderBy, int startIndex, int count, int[] totalRecords)
	// throws EntityException;

}
